package com.example.myapplication;

import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

/**
 * 详情页 Activity
 * 展示推荐内容的详细信息
 */
public class DetailActivity extends AppCompatActivity {
    private TextView tvTitle;
    private TextView tvCategory;
    private TextView tvDescription;
    private TextView tvId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);

        // 初始化控件
        tvTitle = findViewById(R.id.tv_detail_title);
        tvCategory = findViewById(R.id.tv_detail_category);
        tvDescription = findViewById(R.id.tv_detail_description);
        tvId = findViewById(R.id.tv_detail_id);

        // 接收传递过来的数据
        RecommendItem item = (RecommendItem) getIntent().getSerializableExtra("item");

        if (item != null) {
            tvTitle.setText(item.getTitle());
            tvCategory.setText("分类：" + item.getCategory());
            tvDescription.setText(item.getDescription());
            tvId.setText("ID：" + item.getId());
        }
    }
}
